import 'package:flutter/material.dart';

import '../../../theme/theme_color.dart';
import '../../login/Login_pass.dart';
import '../../user/Settings/logoutSendCode_v2.dart';
import '../../../utils/provider.dart';

class UpdateDialog extends Dialog {
  const UpdateDialog({super.key});
  // UpdateDialog();

  @override
  Widget build(BuildContext context) {
    double _width = MediaQuery.of(context).size.width;



    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.end,
        children: <Widget>[
          Container(
            width: _width,
            height: 174,
            margin: EdgeInsets.only(left: 0, right: 0, bottom: 0),
            color: Colors.white,
            child: Stack(
              children: <Widget>[
                GestureDetector(
                  child: Container(
                    width: 15,
                    height: 15,
                    margin: EdgeInsets.only(left: _width - 30, top: 10),
                    child: Icon(Icons.close),
                  ),
                  onTap: () {

                    Navigator.of(context).pop();
                  },
                ),
                Container(
                  width: double.infinity,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: <Widget>[
                      SizedBox(
                        height: 32,
                      ),
                      Text('短信验证',
                          style: TextStyle(
                              fontSize: 16,
                              color: Colors.black,
                              decoration: TextDecoration.none)),
                      SizedBox(
                        height: 10,
                      ),
                      Text('请使用手机 +${(Provider.mobile)}发送短信进行验证',
                          style: TextStyle(
                              fontSize: 16,
                              color: ThemeColor.textColorSecond,
                              decoration: TextDecoration.none)),
                      GestureDetector(
                        child: Container(
                            margin:  EdgeInsets.fromLTRB(59, 15, 59, 0),
                            height: 45,
                            decoration: ShapeDecoration(
                              shape: RoundedRectangleBorder(
                                  borderRadius: BorderRadius.circular(22.5)),
                              color:  Color(0xFF7F69D9),
                            ),
                            width: double.maxFinite,
                            child:  Center(
                              child: Text(
                                "本机发送验证码",
                                style: TextStyle(
                                  color: Colors.white,
                                  fontSize: 18,
                                  fontWeight: FontWeight.bold,
                                ),
                              ),
                            )),
                        onTap: () {
                          Navigator.of(context).pop();
                          Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context){
                            // Navigator.of(context).pop();
                            return SendCodeSecondUI();
                          }));
                          // Navigator.of(context).push(MaterialPageRoute(builder: (ctx) => const SendCodeSecondUI()));
                          // Navigator.of(context).pop();

                        },
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  static showUpdateDialog(
      BuildContext context) {
    return showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return WillPopScope(
              child: UpdateDialog(),onWillPop: _onWillPop);
        });
  }

  static Future<bool> _onWillPop() async{
    return false;
  }
}
